package com.example.covid19.mapper;

import com.example.covid19.common.Dto.goodsDto;
import com.example.covid19.entity.Goods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author BaiZhengChun
 * @since 2022-09-12
 */
public interface GoodsMapper extends BaseMapper<Goods> {
    @Select("SELECT " +
            " order_info.sid, " +
            " order_info.goodsid, " +
            " order_info.ordernumber, " +
            " COUNT(*)  " +
            "FROM " +
            " order_info  " +
            "WHERE " +
            " order_info.ordernumber = #{ordernumber}" +
            "GROUP BY  " +
            "  `sid`")
    Object goodsinfo(@Param("ordernumber") String ordernumber);
    @Select("SELECT " +
            " *,  " +
            " picp.picpath AS picture " +
            "FROM " +
            " goods " +
            " INNER JOIN " +
            " picp " +
            " ON  " +
            " goods.picid = picp.picid")
    List<goodsDto> gooinfo();
    @Select("SELECT " +
            " *,  " +
            " picp.picpath AS picture " +
            "FROM " +
            " goods " +
            " INNER JOIN " +
            " picp " +
            " ON  " +
            " goods.picid = picp.picid "+
            " LIMIT #{pageNo}, #{pagesize} ")
    List<goodsDto> gooinfo2(@Param("pageNo")Integer pageNo,@Param("pagesize")Integer pagesize);
    @Select("SELECT " +
            " picp.picpath,  " +
            " manufacturer.upname,  " +
            " goods.* " +
            "FROM " +
            " goods " +
            " INNER JOIN " +
            " picp " +
            " ON  " +
            " goods.picid = picp.picid " +
            " INNER JOIN " +
            " manufacturer " +
            " ON  " +
            " goods.isup = manufacturer.isup " +
            "WHERE " +
            " goods.picid = picp.picid AND " +
            " goods.isup = manufacturer.isup"+
            " LIMIT #{pageNo}, #{pagesize} "
           )
    List<goodsDto> gooinfo3(@Param("pageNo")Integer pageNo,@Param("pagesize")Integer pagesize);


    @Select("SELECT " +
            " picp.picid " +
            "FROM " +
            " picp " +
            " INNER JOIN " +
            " goods " +
            " ON  " +
            " picp.picid = goods.picid " +
            "WHERE " +
            " #{sid} = picp.picid")
    Object goopic(@Param("sid") String sid);

}
